草庐IT

Android MediaCodec dequeueInputBuffer 总是返回 -1

全部标签

c# - 如何在 EF6 异步中启动实体存储过程而不等待返回?

我只想将调用发送到SQLServer,而不是等待返回。我有一个从存储过程导入的实体函数,我想在EntityFramework6.0.0-rc1中以这种方式异步调用它。这可能吗?语法是什么?EntityFunction:RecalculateBudgetNumbers(intid) 最佳答案 启动一个新的Task,创建一个新的数据上下文并调用该函数。只是不要等待/等待该任务。让它自己运行直到完成。确保记录错误。不要吞下异常,因为它们可能是您想了解的错误。在ASP.NET设置中,请注意工作进程可以随时回收,因此您的后台工作可能会突然消失

c# - 为什么 DbSet Add 返回的是实体实例而不是 void?

DbSet.Add方法返回一个实体。我通常会期待Add操作有void返回类型。当我查看EntityFrameworksourcecode,我看到了以下实现:publicvirtualTEntityAdd(TEntityentity){Check.NotNull(entity,"entity");GetInternalSetWithCheck("Add").Add(entity);returnentity;}GetInternalSetWithCheck返回InternalSetAddInternalSet的方法|有趣的是,它的签名中有一个void返回类型:publicvirtualvo

c# - Sum() 在 Entity Framework 查询中返回 null

我有一个包含这些行的大型EntityFramework查询。varprograms=frompinRepository.Query()wherep.OfficeId==CurrentOffice.IdlettotalCharges=p.ProgramBillings.Where(b=>b.Amount>0&&b.DeletedDate==null).Select(b=>b.Amount).Sum()lettotalCredits=p.ProgramBillings.Where(b=>b.Amount-b.Amount).Sum()letbillingBalance=(totalChar

c# - HtmlAgilityPack 和 Selenium Webdriver 返回随机结果

我正在尝试从网站上抓取产品名称。奇怪的是,我似乎只随机抓取了12个项目。我已经尝试了HtmlAgilityPack和HTTPClient,我得到了相同的随机结果。这是我的HtmlAgilityPack代码:usingHtmlAgilityPack;usingSystem.Net.Http;varurl=@"http://www.roots.com/ca/en/men/tops/shirts-and-polos/";HtmlWebweb=newHtmlWeb();vardoc=web.Load(url,"GET",proxy,newNetworkCredential(PROXY_UID,

c# - ConfigurationManager 返回 null 而不是字符串值

我正在尝试从存储在我的工作目录中的App.config文件中检索值,但是当我运行该程序时它返回null。我很困惑为什么会这样,并且多次查看代码以试图发现错误。这是我的App.config文件代码:这是我的C#代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Configuration;usingSystem.Data;usingSystem.Data.Common;namespaceDataProviderFun{classProgram{static

c# - T4 模板错误 : loading the include file ef. utility.cs.ttinclude 返回了 null 或空字符串

我已经覆盖了Controller生成T4模板(ControllerWithContext.tt),如here所述.我想利用在POCO模型生成器T4模板中使用的EF.utility.CS.ttinclude中的代码帮助实用程序。因此,我将以下行从我的Model.tt复制到我的ControllerWithContext.tt。但是,当我尝试添加Controller时,我收到了错误消息Loadingtheincludefile'EF.utility.CS.ttinclude'returnedanulloremptystring根据MSDNdocumentation,这个错误是因为包含的文件是

c# - 在 F# 中正确等待返回类型为 Task<T> 的异步 C# 方法

我希望能够从F#使用C#库。大多数情况下,这非常简单。但是,如果我尝试调用返回Task的函数我无法获得返回值。所以,我有具有以下定义的C#方法:publicasyncTaskReadEventAsync(stringstreamName,intposition)whereTEvent:class我正在尝试使用F#中的这个方法,如下所示:letreadEventFromEventStore(eventStore:IEventStoreRepository)(streamName:string)(position:int)=async{returneventStore.ReadEventA

c# - 从 .NET Core Controller 返回 CSV

我在将.NETCoreAPIController端点解析为CSV下载时遇到问题。我正在使用从.NET4.5Controller中提取的以下代码:[HttpGet][Route("{id:int}")]publicasyncTaskGet(intid){stringcsv=awaitreportManager.GetReport(CustomerId,id);varresponse=newHttpResponseMessage(HttpStatusCode.OK);response.Content=newStringContent(csv);response.Content.Header

c# - 每次使用 Moq 调用方法时,如何使 Mock 返回一个新列表

我正在使用MOQ模拟具有预期返回列表的方法调用。我的方法返回一个列表,但我希望模拟在每次调用该方法时创建一个新列表。到目前为止我做了什么:Listexpected=newList{newCorrelation(){Code="SelfError1"},newCorrelation(){Code="SelfError2"}};MockselfMock=newMock();selfMock.Setup(f=>f.Validate()).Returns(expected);我想要实现的是让模拟在每次调用方法get时返回一个新列表。我试过这个但没用:selfMock.Setup(f=>f.Va

c# - IDisposable 在方法中创建并返回

我很高兴编写了一个运行良好且在运行时不会出现任何异常的项目。所以我决定运行静态代码分析工具(我使用的是VisualStudio2010)。结果发现违反了规则CA2000,消息如下:警告-CA2000:Microsoft.Reliability:在方法“Bar.getDefaultFoo()”中,在对对象“newFoo()”的所有引用超出范围之前调用System.IDisposable.Dispose。引用的代码是这样的:privatestaticIFoogetDefaultFoo(){return(Baz.canIDoIt())?newFoo():null;}我自己想:也许条件表达式破